package stud.aistar.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import stud.aistar.mapper.MedicineVoMapper;
import stud.aistar.service.IMedicineVoService;
import stud.aistar.vo.MedicineVo;

import java.util.List;

/**
 * *
 *
 * @ClassName :wangyu
 * @Description:药品service
 * @Author
 * @Date2019/9/28 19:15
 * @Version V1.0
 */
@Service
@Transactional
public class MedicineVoServiceImpl implements IMedicineVoService {

    @Autowired
    private MedicineVoMapper mapper;

    @Override
    public PageInfo<MedicineVo> findAll(Integer pageNum, Integer pageSize,String medName) {
        //分页
        PageHelper.startPage(pageNum,pageSize);

        List<MedicineVo> list = mapper.findAll(medName);

        PageInfo<MedicineVo> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }

    @Override
    public List<MedicineVo> findByMedName(String medName) {

        List<MedicineVo> list = mapper.findByMedName(medName);
        return list;
    }

    @Override
    public List<MedicineVo> findByIllmedId(Integer illmedId) {
        List<MedicineVo> list = findByIllmedId(illmedId);
        return list;
    }

    @Override
    public PageInfo<MedicineVo> finIlldAll(Integer pageNum, Integer pageSize, Integer illmedId) {

        PageHelper.startPage(pageNum,pageSize);

        List<MedicineVo> list = mapper.findByIllmedId(illmedId);

        PageInfo<MedicineVo> pages = new PageInfo<>(list);

        return pages;
    }
}
